use async_trait::async_trait;
use base_data::channel::EndReason;
use tools::ResultNull;
use tracing::info;

use crate::{
	business::{
		bus_trait::Business,
		inbound400::context::{BusinessState, InboundRunContext},
	},
	db::persistence::InboundDBO,
};

#[derive(Debug, Clone)]
pub struct DialTestIn;

#[async_trait]
impl Business for DialTestIn {
	type C = InboundRunContext;

	async fn start_call(&self, context: &mut Self::C) -> ResultNull {
		info!("拨测呼入");

		//上来就挂断通话？
		context.business_state = BusinessState::End(EndReason::DialTest);

		//上传收到拨测内容
		InboundDBO::callin_dial_test_up(
			&context.caller_num(),
			&context.target(),
			EndReason::DialTest,
		)
		.await?;

		Ok(())
	}
}
